local douhen = fk.CreateSkill{
  name = "lingling__douhen",
}

Fk:loadTranslationTable{
  ["lingling__douhen"] = "斗狠",
  [":lingling__douhen"] = "出牌阶段限一次，你可以失去1点体力，令一名其他角色弃置任意张牌，然后你可以弃置X张牌对其造成2点伤害（X为其弃置牌数+1）。",

  ["#lingling__douhen"] = "斗狠：失去1点体力，令一名角色弃置任意张牌，你可以多弃一张对其造成2点伤害！",
  ["#lingling__douhen-discard"] = "斗狠：弃置任意张牌，%src 可以多弃一张对你造成2点伤害！",
  ["#lingling__douhen-damage"] = "斗狠：你可以弃置%arg张牌，对 %dest 造成2点伤害！",
}

douhen:addEffect("active", {
  anim_type = "offensive",
  prompt = "#lingling__douhen",
  card_num = 0,
  target_num = 1,
  can_use = function(self, player)
    return player:usedSkillTimes(douhen.name, Player.HistoryPhase) == 0 and player.hp > 0
  end,
  card_filter = Util.FalseFunc,
  target_filter = function(self, player, to_select, selected)
    return #selected == 0 and to_select ~= player
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    room:loseHp(player, 1, douhen.name)
    if target.dead then return end
    local cards = room:askToDiscard(target, {
      min_num = 1,
      max_num = 999,
      include_equip = true,
      skill_name = douhen.name,
      cancelable = true,
      prompt = "#lingling__douhen-discard:"..player.id,
    })
    if player.dead or #player:getCardIds("he") <= #cards then return end
    local n = #cards + 1
    if #room:askToDiscard(player, {
      min_num = n,
      max_num = n,
      include_equip = true,
      skill_name = douhen.name,
      cancelable = true,
      prompt = "#lingling__douhen-damage::"..target.id..":"..n,
    }) == n and not target.dead then
      room:damage{
        from = player,
        to = target,
        damage = 2,
        skillName = douhen.name,
      }
    end
  end,
})

return douhen
